<template>
	<view class="template-screen tn-safe-area-inset-bottom">



		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed :isBack="false" :bottomShadow="false" backgroundColor="#FFFFFF">
			<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
				<!-- 图标logo -->
				<view class="custom-nav__back">
					<view class="logo-pic tn-shadow-blur"
						style="background-image:url('https://xq.michuang.top/logo.png')">
						<view class="logo-image">
						</view>
					</view>
					<!-- <view class="tn-icon-left"></view> -->
				</view>
				<!-- 搜索框 -->
				<view class="custom-nav__search tn-flex tn-flex-col-center tn-flex-row-center " @click="tn('/pages/main/tabbar/tabbar-2/search')">
					<view
						class="custom-nav__search__box tn-flex tn-flex-col-center tn-flex-row-left tn-color-gray--dark tn-bg-gray--light">
						<view class="custom-nav__search__icon tn-icon-search"></view>
						<view class="custom-nav__search__text tn-padding-left-xs">搜搜八段锦</view>
					</view>
				</view>
			</view>
		</tn-nav-bar>

		<!-- 页面内容 -->
		<view class="bg-contaniner " :style="{ 'background-color': hbgcolor }">

		</view>
		<view class="tn-margin-top-lg">
			<view class="tn-padding" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
				<tn-swiper @click="click" :list="banner" :height="280" :effect3d="true" mode="dot" ></tn-swiper>
			</view>
			<!-- 方式10 start-->
			<view class="tn-flex tn-margin-top" style="background-color:#FFF;">
				<view class="tn-flex-1 tn-padding-sm tn-margin-xs tn-radius" @click="tn('/pages/main/tabbar/tabbar-2/yundong')">
					<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
						<view
							class="icon10__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-bg-blue tn-color-white">
							<view class="tn-icon-sport-jog"></view>
						</view>
						<view class="tn-color-black tn-text-lg tn-text-center">
							<text class="tn-text-ellipsis">锻炼</text>
						</view>
					</view>
				</view>
				<view class="tn-flex-1 tn-padding-sm tn-margin-xs tn-radius" @click="tn('/pages/main/tabbar/tabbar-2/preferred')">
					<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
						<view
							class="icon10__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-bg-cyan tn-color-white">
							<view class="tn-icon-food"></view>
						</view>
						<view class="tn-color-black tn-text-lg tn-text-center">
							<text class="tn-text-ellipsis">饮食</text>
						</view>
					</view>
				</view>

				<view class="tn-flex-1 tn-padding-sm tn-margin-xs tn-radius"  @click="tn('/pages/main/tabbar/tabbar-2/baike')">
					<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
						<view
							class="icon10__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-bg-purple tn-color-white">
							<view class="tn-icon-creative-fill"></view>
						</view>
						<view class="tn-color-black tn-text-lg tn-text-center">
							<text class="tn-text-ellipsis">百科</text>
						</view>
					</view>
				</view>
				<view class="tn-flex-1 tn-padding-sm tn-margin-xs tn-radius"  @click="tn('/pages/main/tabbar/tabbar-2/about')">
					<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
						<view
							class="icon10__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-bg-red tn-color-white">
							<view class="tn-icon-vip-diamond-fill"></view>
						</view>
						<view class="tn-color-black tn-text-lg tn-text-center">
							<text class="tn-text-ellipsis">关于我们</text>
						</view>
					</view>
				</view>
			</view>
			<!-- 方式10 end-->

		</view>


		<view style="background-color: #FFF;">


			<view>
				<view class="tn-flex tn-flex-row-between">
					<view class="justify-content-item tn-margin tn-text-bold tn-text-xl">
						今日推荐
					</view>
					<view class="tn-margin" style="font-size: 50rpx;">
						<text class="tn-icon-data"></text>
					</view>
				</view>
			</view>

			<swiper class="card-swiper" :circular="true" :autoplay="true" duration="500" interval="2500"
				@change="cardSwiper">
				<swiper-item v-for="(item,index) in swiperList" :key="index" :class="cardCur==index?'cur':''">
					<!-- <view class="swiper-item image-banner">
		         <image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
		       </view> -->
					<view  @click="tn(item.link)"  class="swiper-item image-banner tn-shadow-blur"
						:style="'background-image:url('+ item.url + ');background-size: cover;border-radius: 15rpx;'">
					</view>
					<view class="swiper-item-text card-shadow">
						<view class="tn-text-xxl tn-text-bold">{{item.name}}</view>
						<view class="tn-text-sm tn-text-bold tn-padding-top-xs">{{item.text}}</view>
					</view>
				</swiper-item>
			</swiper>
			<view class="indication">
				<block v-for="(item,index) in swiperList" :key="index">
					<view class="spot" :class="cardCur==index?'active':''"></view>
				</block>
			</view>




			<view class="" style="margin-top: -20rpx;">
				<view class="tn-flex tn-flex-row-between">
					<view class="justify-content-item tn-margin tn-text-bold tn-text-xl">
						热门搜索
					</view>
					<view class="tn-margin" style="font-size: 50rpx;">
						<text class="tn-icon-data"></text>
					</view>
				</view>
			</view>

			<view class="tn-margin-left tn-text-sm tn-color-gray" style="margin-top: -25rpx;">
				<text>这是今日热门话题，请查收吖</text>
			</view>

			<view class="">
				<view class="tn-plan-content tn-margin tn-text-justify">
					<view v-for="(item,index) in planList" :key="index"
						class="tn-plan-content__item tn-margin-right tn-round tn-text-sm tn-text-bold"
						:class="[`tn-bg-${item.color}--light tn-color-${item.color}`]"  @click="tn('/pages/main/tabbar/tabbar-2/search?word=' + item.name)">
						<text class="tn-plan-content__item--prefix">#</text> {{item.name}}
					</view>
				</view>
			</view>

			<view class="" style="margin-top: 50rpx;">
				<view class="tn-flex tn-flex-row-between">
					<view class="justify-content-item tn-margin tn-text-bold tn-text-xl">
						热门阅读
					</view>
					<view class="tn-margin" style="font-size: 50rpx;">
						<text class="tn-icon-data"></text>
					</view>
				</view>
			</view>

			<view class="tn-margin-left tn-text-sm tn-color-gray" style="margin-top: -25rpx;">
				<text>这是今日热门的阅读文章，请查收吖</text>
			</view>


			<!-- 不建议写时间，因为写了时间，你就要经常更新文章了鸭-->
			<view class="">
				<block v-for="(item, index) in hotArticle" :key="index">
					<view class="article-shadow tn-margin" @click="tn('/pages/main/tabbar/tabbar-2/details?id=' + item.id)">
						<view class="tn-flex">
							<view class="image-pic tn-margin-sm"
								:style="'background-image:url(' + item.cover_image + ')'">
								<view class="image-article">
								</view>
							</view>
							<view class="tn-margin-sm tn-padding-top-xs" style="width: 100%;">
								<view class="tn-text-lg tn-text-bold clamp-text-1 tn-text-justify">
									{{ item.title }}
								</view>
								<view class="tn-padding-top-xs" style="min-height: 105rpx;">
									<text class="tn-text-df tn-color-gray clamp-text-2 tn-text-justify">
										{{ item.desc }}
									</text>
								</view>
								<view class="tn-flex tn-flex-row-between tn-flex-col-between">
									<view v-for="(tags_item,tags_index) in item.tags" :key="tags_index"
										class="justify-content-item tn-tag-content__item tn-margin-right tn-round tn-text-sm tn-text-bold"
										:class="[`tn-bg-${item.color}--light tn-color-${item.color}`]">
										<text class="tn-tag-content__item--prefix">#</text> {{ tags_item }}
									</view>
									<view
										class="justify-content-item tn-color-gray tn-text-center tn-color-gray--disabled"
										style="padding-top: 5rpx;">
										<text class="tn-icon-footprint tn-padding-right-xs tn-text-lg"></text>
										<text class="tn-padding-right tn-text-df">{{ item.view_count }}</text>
										<text class="tn-icon-like tn-padding-right-xs tn-text-lg"></text>
										<text class="tn-text-df">{{ item.like_count }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</block>
			</view>



		</view>

		
		<!-- 回到首页悬浮按钮-->
		<nav-index-button></nav-index-button>

	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	import NavIndexButton from '@/libs/components/nav-index-button.vue'
	import hotPage from '@/pages/main/tabbar/tabbar-2/hot.vue'
	export default {
		name: 'TemplateScreen',
		mixins: [template_page_mixin],
		components: {
			NavIndexButton,
			hotPage
		},
		data() {
			return {
				hbgcolor: '#FFF',
				banner: [],
				cardCur: 0,
				swiperList: [],			
				planList: [],
				hotArticle: []
			}
		},
		onLoad() {
			this.getBanner()
			this.getCardBanner()
			this.getArticleList()
			this.getplanList()
		},
		methods: {
			click(e) {
				uni.navigateTo({
					url:e
				})
				// console.log(e)
			 
			},
			getBanner() {
				// 在你的uniapp页面或组件中使用以下代码
				uni.request({
					url: 'https://xq.michuang.top/api/index/getBannerData',
					method: 'POST',
					data: {
						// Your request parameters go here
						type: 'index',

						// Add more parameters as needed
					},
					success: (res) => {
						if (res.data) {
							// 成功获取数据
							// 更新轮播图数据
							this.banner = res.data.data;
						} else {
							// 处理请求失败的情况
							console.error('接口请求失败');
						}
					},
					fail: (err) => {
						// 处理请求失败的情况
						console.error('接口请求失败', err);
					}
				});

			},
			getCardBanner() {
				// 在你的uniapp页面或组件中使用以下代码
				uni.request({
					url: 'https://xq.michuang.top/api/index/getBannerData',
					method: 'POST',
					data: {
						// Your request parameters go here
						type: 'hot',

						// Add more parameters as needed
					},
					success: (res) => {
						if (res.data) {
							// 成功获取数据
							// 更新轮播图数据
							
							this.swiperList = res.data.data;
						} else {
							// 处理请求失败的情况
							console.error('接口请求失败');
						}
					},
					fail: (err) => {
						// 处理请求失败的情况
						console.error('接口请求失败', err);
					}
				});

			},
			getArticleList() {
				// 在你的uniapp页面或组件中使用以下代码
				uni.request({
					url: 'https://xq.michuang.top/api/index/getArticleList',
					method: 'POST',
					
					success: (res) => {
						if (res.data) {
							// 成功获取数据
							// 更新轮播图数据
							this.hotArticle = res.data.data;
						} else {
							// 处理请求失败的情况
							console.error('接口请求失败');
						}
					},
					fail: (err) => {
						// 处理请求失败的情况
						console.error('接口请求失败', err);
					}
				});
			
			},
			getplanList(){
				uni.request({
					url: 'https://xq.michuang.top/api/index/searchWord',
					method: 'POST',
					
					success: (res) => {
						if (res.data) {
							// 成功获取数据
							// 更新轮播图数据
							this.planList = res.data.data;
						} else {
							// 处理请求失败的情况
							console.error('接口请求失败');
						}
					},
					fail: (err) => {
						// 处理请求失败的情况
						console.error('接口请求失败', err);
					}
				});
			},
			// cardSwiper
			cardSwiper(e) {
			  this.cardCur = e.detail.current
			},
			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/templatePage/custom_nav_bar.scss';

	/* 自定义导航栏内容 start */
	.custom-nav {
		height: 100%;

		&__back {
			margin: auto 5rpx;
			font-size: 40rpx;
			margin-right: 10rpx;
			margin-left: 30rpx;
			flex-basis: 5%;
		}

		&__search {
			flex-basis: 60%;
			width: 100%;
			height: 100%;

			&__box {
				width: 100%;
				height: 70%;
				padding: 10rpx 0;
				margin: 0 30rpx;
				border-radius: 60rpx 60rpx 0 60rpx;
				font-size: 24rpx;
			}

			&__icon {
				padding-right: 10rpx;
				margin-left: 20rpx;
				font-size: 30rpx;
			}

			&__text {
				color: #AAAAAA;
			}
		}
	}

	/*logo start */
	.logo-image {
		width: 65rpx;
		height: 65rpx;
		position: relative;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 50%;
	}

	/* 自定义导航栏内容 end */

	.screen-shadow {
		box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.07);
		border-radius: 20rpx;
	}

	/* 图标容器10 start */
	.icon10 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 84rpx;
				height: 65rpx;
				font-size: 45rpx;
				border-radius: 200rpx;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg6.png);
				}
			}
		}
	}

	/* 图标容器10 end */

	/* 移动背景部分 start*/
	// .bg-contaniner {
	// 	position: fixed;
	// 	top: -0rpx;
	// 	left: -300rpx;
	// 	--text-color: hsl(0 95% 60%);
	// 	--bg-color: hsl(0 0% 100%);
	// 	--bg-size: 200px;
	// 	height: 100%;
	// 	display: grid;
	// 	place-items: center;
	// 	place-content: center;
	// 	overflow: hidden;
	// 	background-color: var(--bg-color);
	// 	z-index: -1;
	// }

	// .bg-contaniner::before {
	// 	--size: 150vmax;

	// 	content: "";
	// 	inline-size: var(--size);
	// 	block-size: var(--size);
	// 	background-image: url("https://xq.michuang.top/1.png");
	// 	background-size: var(--bg-size);
	// 	background-repeat: repeat;
	// 	transform: rotate(45deg);
	// 	opacity: 0.25;
	// 	animation: bg 6s linear infinite;
	// }

	@media (prefers-reduced-motion: reduce) {
		.bg-contaniner::before {
			animation-duration: 0s;
		}
	}

	@keyframes bg {
		to {
			background-position: 0 calc(var(--bg-size) * -1);
		}
	}

	/* 移动背景部分 end*/
	/* 胶囊*/
	.tn-custom-nav-bar__back {
		width: 100%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		box-sizing: border-box;
		background-color: rgba(0, 0, 0, 0.15);
		border-radius: 1000rpx;
		border: 1rpx solid rgba(255, 255, 255, 0.5);
		color: #FFFFFF;
		font-size: 18px;

		.icon {
			display: block;
			flex: 1;
			margin: auto;
			text-align: center;
		}

		&:before {
			content: " ";
			width: 1rpx;
			height: 110%;
			position: absolute;
			top: 22.5%;
			left: 0;
			right: 0;
			margin: auto;
			transform: scale(0.5);
			transform-origin: 0 0;
			pointer-events: none;
			box-sizing: border-box;
			opacity: 0.7;
			background-color: #FFFFFF;
		}
	}

	/* 轮播 start*/
	.card-swiper {
		height: 570rpx !important;
	}

	.card-swiper swiper-item {
		width: 450rpx !important;
		left: 30rpx;
		box-sizing: border-box;
		padding: 0rpx 0rpx 80rpx 0rpx;
		overflow: initial;
	}

	.card-swiper swiper-item .swiper-item {
		width: 100%;
		display: block;
		height: 100%;
		border-radius: 10rpx;
		transform: scale(0.7) translate(0rpx, -104rpx);
		transition: all 0.3s ease-in 0s;
		will-change: transform;
		// overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item {
		transform: none;
		transition: all 0.3s ease-in 0s;
		will-change: transform;
	}

	.card-swiper swiper-item .swiper-item-text {
		margin-top: -100rpx;
		width: 100%;
		display: block;
		height: 50%;
		border-radius: 10rpx;
		transform: translate(20rpx, -30rpx) scale(0.7, 0.7);
		transition: all 0.4s ease 0s;
		will-change: transform;
		overflow: hidden;
		color: #000000;
		// background-image: linear-gradient(rgba(255, 255, 255, 0), rgba(0, 0, 0, 0));
		height: 140rpx;
	}

	.card-swiper swiper-item.cur .swiper-item-text {
		margin-top: -150rpx;
		padding-left: 30rpx;
		width: 500rpx !important;
		transform: translate(-25rpx, 20rpx) scale(0.9, 0.9);
		transition: all 0.4s ease 0s;
		will-change: transform;
		color: #FFFFFF;
		text-shadow: 0rpx 10rpx 20rpx rgba(0, 0, 0, 0.1);
		// background-image: linear-gradient(rgba(255, 255, 255, 0.01), rgba(0, 0, 0, 0.4));
		height: 137rpx;
	}

	.image-banner {
		display: flex;
		align-items: center;
		justify-content: center;
		// border: 1rpx solid red;
	}

	.image-banner image {
		width: 100%;
		height: 100%;
	}

	/* 轮播指示点 start*/
	.indication {
		z-index: 9999;
		width: 100%;
		height: 36rpx;
		position: absolute;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}

	.spot {
		background-color: #000;
		opacity: 0.4;
		width: 10rpx;
		height: 10rpx;
		border-radius: 20rpx;
		margin: 0 8rpx !important;
		right: -270rpx;
		top: -100rpx;
		position: relative;
	}

	.spot.active {
		opacity: 1;
		width: 10rpx;
		background-color: #000;
	}

	/* 计划内容 start*/
	.tn-plan-content {
		&__item {
			display: inline-block;
			line-height: 45rpx;
			padding: 10rpx 30rpx;
			margin: 20rpx 20rpx 5rpx 0rpx;

			&--prefix {
				padding-right: 10rpx;
			}
		}
	}

	.tn-plan-content2 {
		&__item {
			line-height: 45rpx;
			padding: 15rpx 30rpx;
			margin: 30rpx 0rpx 10rpx 0rpx;

			&--prefix {
				padding-right: 10rpx;
			}
		}
	}

	/* 计划内容 end*/

	/* 资讯主图 start*/
	.image-article {
		border-radius: 8rpx;
		border: 1rpx solid #F8F7F8;
		width: 200rpx;
		height: 200rpx;
		position: relative;
	}

	.image-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 10rpx;
	}

	.article-shadow {
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	/* 文字截取*/
	.clamp-text-1 {
		-webkit-line-clamp: 1;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.clamp-text-2 {
		-webkit-line-clamp: 2;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	/* 标签内容 start*/
	.tn-tag-content {
		&__item {
			display: inline-block;
			line-height: 35rpx;
			padding: 5rpx 25rpx;

			&--prefix {
				padding-right: 10rpx;
			}
		}
	}

	/* 底部tabbar start*/
	.footerfixed {
		position: fixed;
		width: 100%;
		bottom: 0;
		z-index: 999;
		background-color: #FFFFFF;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.tabbar {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		justify-content: space-between;
		padding: 0;
		height: calc(110rpx + env(safe-area-inset-bottom) / 2);
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
	}

	.tabbar .action {
		font-size: 22rpx;
		position: relative;
		flex: 1;
		text-align: center;
		padding: 0;
		display: block;
		height: auto;
		line-height: 1;
		margin: 0;
		overflow: initial;
	}

	.tabbar .action .bar-icon {
		width: 100rpx;
		position: relative;
		display: block;
		height: auto;
		margin: 0 auto 10rpx;
		text-align: center;
		font-size: 42rpx;
		// line-height: 50rpx;
	}

	.tabbar .action .bar-icon image {
		width: 50rpx;
		height: 50rpx;
		display: inline-block;
	}

	.tabbar .action .bar-circle {
		position: relative;
		display: block;
		margin: -30rpx auto 20rpx;
		text-align: center;
		font-size: 52rpx;
		line-height: 90rpx;
		background-color: #FFCA28;
		width: 90rpx !important;
		height: 90rpx !important;
		overflow: hidden;
		border-radius: 50%;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(255, 202, 40, 0.5);
	}

	.tabbar .action .bar-circle image {
		width: 60rpx;
		height: 60rpx;
		display: inline-block;
		margin: 15rpx auto 15rpx;
	}
</style>